package com.soushin.mvpdemo.module.bigimage;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import com.soushin.mvpdemo.R;
import com.soushin.mvpdemo.base.BaseActivity;

/**
 * 查看大图
 *
 * @author SouShin
 * @time 2018/11/14 15:08
 */
public class BigImageActivity extends BaseActivity<BigImageView, BigImagePresenter> implements BigImageView, BaseQuickAdapter.OnItemClickListener{

    @BindView(R.id.rv_photo_view)
    RecyclerView rvPhotoView;
    private BigImageAdapter bigAdapter;

    @Override
    protected BigImagePresenter createPresenter() {
        return new BigImagePresenter();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_big_image;
    }

    @Override
    protected void bindView() {
        getPresenter().subscribe(this);
    }

    @Override
    public void initView() {
        bigAdapter = new BigImageAdapter();
        bigAdapter.setOnItemClickListener(this);
        rvPhotoView.setHasFixedSize(true);
        rvPhotoView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
        rvPhotoView.setAdapter(bigAdapter);
    }

    @Override
    public void setImageList(List<String> list) {
        bigAdapter.setNewData(list);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        showImageList((ArrayList<String>) bigAdapter.getData(),rvPhotoView,position);
    }

}
